package com.dao.impl;

import java.lang.reflect.ParameterizedType;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.dao.GenericDao;
import com.dao.UniversalDao;

@SuppressWarnings("unchecked")
public class GenericDaoImpl<T> extends HibernateDaoSupport implements GenericDao<T> {
    
    protected Class<T> clazz;
    
    @Resource
    SessionFactory sessionFactory;
    
    @Resource
    protected UniversalDao universalDao;
    
    @PostConstruct
    public void setSF() {
        super.setSessionFactory(sessionFactory);
    }

    public GenericDaoImpl() {
        clazz = (Class<T>)((ParameterizedType)getClass().getGenericSuperclass()).getActualTypeArguments()[0];
    }

    @Override
    public void save(T t) {
        getHibernateTemplate().save(t);
    }
    
}
